//公共地址配置 发布时需要根据配置文件生成
window.jkconfig = {
    // weburl: "http://118.25.1.144:9991/",//web域名
    // webupdateurl: "http://118.25.1.144:8126",//系统更新
    // webapiurlv: "http://118.25.1.144:8125/api/v1/web/",//接口域名
    // sysapiurlv: "http:/118.25.1.144:8125/api/v1/admin/"//接口域名,
    weburl: "/",//web域名
    webupdateurl: "http://127.0.0.1:8126",//系统更新
    webapiurlv: "http://127.0.0.1:8125/api/v1/web/",//接口域名
    sysapiurlv: "http://127.0.0.1:8125/api/v1/admin/"//接口域名,

};
var baseURL = window.jkconfig.webapiurlv;//临时用
var api_key = "api_key", platformId = "platformId", platformName = "platformName";
var token = localStorage[api_key];
var platformId = localStorage[platformId];
var platformName = localStorage[platformName];
//jquery全局配置
$.ajaxSetup({
    dataType: "json",
    cache: false,
    headers: {
        "api_key": token
    },
    xhrFields: {
        withCredentials: true
    },
    complete: function (xhr) {
        //token过期，则跳转到登录页面
        if (xhr.responseJSON.code == 401) {
            parent.location.href = '/login.html';
        }
    },
    error: function (jqXHR, textStatus, errorThrown) {
        if (jqXHR.status === 401) {
            window.top.location.href = '/login.html';
        } else {
            console && console.log(jqXHR);
        }
    }
});

function showF(a) {
    $(".pt-int-content").css("left", $(a).offset().left - 12);
    // $(".pt-int-content").css("top", $(a).offset().top + 20 - $(".header").height() - $(".header-r").height() - $(".system-info-fs").height());
    $(".pt-int-content").css("top", $(a).offset().top + 20);
    $(".p-i-box").html($(a).attr("alt"));
    $(".pt-int-content").show();
}

function hideF() {
    $(".pt-int-content").hide();
}

/**
 * 获取url参数
 * @param name
 * @returns {*}
 */
window.getQueryString = function (name) {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = window.location.search.substr(1).match(reg);
    if (r != null) {
        return unescape(r[2]);
    }
    return null;
}

// 说明：JS时间Date格式化参数
// 参数：格式化字符串如：'yyyy-MM-dd HH:mm:ss'
// 结果：如2016-06-01 10:09:00
Date.prototype.Format = function (fmt) { //author: meizz
    var o = {
        "M+": this.getMonth() + 1,
        "d+": this.getDate(),
        "H+": this.getHours(),
        "m+": this.getMinutes(),
        "s+": this.getSeconds(),
        "q+": Math.floor((this.getMonth() + 3) / 3),
        "S": this.getMilliseconds()
    };
    var year = this.getFullYear();
    var yearstr = year + '';
    yearstr = yearstr.length >= 4 ? yearstr : '0000'.substr(0, 4 - yearstr.length) + yearstr;

    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (yearstr + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}

seajs.config({
    base: "/js",
    comboExcludes: /\/js*/
});
// arale": "http://static.zlbaba.com/arale",
//
// "gallery": "http://static.zlbaba.com/gallery"
//arale": window.jkconfig.weburl + 'js/arale',
//         //gallery 其他三方组件
//         "gallery": window.jkconfig.weburl + 'js/gallery'
seajs.config({
    debuge: true,
    // 设置路径，方便跨项目调用
    paths: {
        assetsJS: window.jkconfig.weburl + 'plugins/assets/dist/js/',
        // "arale": "http://static.zlbaba.com/arale",
        // "gallery": "http://static.zlbaba.com/gallery"
        arale: window.jkconfig.weburl + 'js/arale',
        gallery: window.jkconfig.weburl + 'js/gallery'
    },
    // 别名配置
    alias: {
        bootstrap: "assetsJS/bootstrap.min.js",
        aceElements: "assetsJS/ace-elements.min.js",
        jquery: "assetsJS/jquery-2.0.3.min.js",
        ace: "assetsJS/ace.min.js",
        bsDialog: "bootstrap3-dialog/js/bootstrap-dialog.min.js",
        Kpublic: "KennyPublic.js",
        less: "less1.3.2/less.min.js",
        // popup: "arale/arale-popup/1.2.0/popup-debug",
        paging: "gallery/bt-paging/1.1.6/index",
        validator: "arale/arale-validator/0.11.0/index-debug.js",
        template: "gallery/arttemplate-native/3.0.2/index",
        arttemplate: "gallery/arttemplate-native/3.0.2/index",
        uri: "gallery/uri/1.0.4/index"
    },
    // 预加载项
    preload: [
        Function.prototype.bind ? '' : 'es5-safe',
        this.jquery ? '' : 'jquery'
    ]
});